﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Agencia.Models;

namespace Agencia.Controllers
{
    [Authorize]
    public class BoletaController : Controller
    {
        private AgenciaBD db = new AgenciaBD();
        private WsAerolinea.Service1 ws = new WsAerolinea.Service1();

        public List<WsAerolinea.Vuelo> Lista_Vuelos(int id)
        {
            var vuelos = ws.Lista_Vuelos();

            var lista = (from v in vuelos
                         where v.Fecha > DateTime.Now
                         && v.Id == id
                         select v).ToList();

            return lista;
        }

        public List<WsAerolinea.Pais> Lista_Paises()
        {
            return ws.Lista_Paises().ToList();
        }

        public ActionResult Index()
        {
            String cliente = User.Identity.Name;
            var boletas = from c in db.Boletas
                          where c.ClienteId == cliente
                          select c;

            return View(boletas.ToList());
        }

        //
        // GET: /Boleta/Details/5

        public ViewResult Details(int id)
        {
            Boleta boleta = db.Boletas.Find(id);
            return View(boleta);
        }

        //
        // GET: /Boleta/Create

        protected override void Dispose(bool disposing)
        {
            db.Dispose();
            base.Dispose(disposing);
        }
    }
}